package com.example.stock.controller;

import com.example.stock.compone.EmaComponent;
import com.example.stock.service.ProBar300Service;
import com.example.stock.service.StockDetailService;
import com.example.stock.service.StockStatService;
import com.example.stock.service.stat.StatService;
import com.example.stock.vo.DataVo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

@RestController
@RequestMapping("/ema")
public class EmaAnalysisController {
    @Resource
    private StatService statService;
    @Resource
    private StockDetailService stockDetailService;
    @Resource
    private EmaComponent emaComponent;
    @Resource
    private StockStatService stockStatService;
    @Resource
    private ProBar300Service proBar300Service;

    @RequestMapping("statistics_30")
    public Object statistics_30() {
        emaComponent.startStatistics();
        List<DataVo> closeData = proBar300Service.getRowData30();
        statService.statisticsEma30(closeData);
        return "success!";

    }

    @RequestMapping("analysis_30")
    public Object analysis_30() {
        List<DataVo> closeData = proBar300Service.getRowData30();
        BigDecimal finalMoney = stockStatService.analysisEmaUpDown(38, 22, closeData,true);
        return finalMoney;
    }

    @RequestMapping("statistics_60")
    public Object statistics_60() {
        emaComponent.startStatistics();
        List<DataVo> closeData = proBar300Service.getRowData60();
        statService.statisticsEma30(closeData);
        return "success!";

    }

    @RequestMapping("analysis_60")
    public Object analysis_60() {
        List<DataVo> closeData = proBar300Service.getRowData60();
        BigDecimal finalMoney = stockStatService.analysisEmaUpDown(20, 11, closeData,true);
        return finalMoney;
    }

    @RequestMapping("statistics")
    public String stat() {
        emaComponent.startStatistics();
        proBar300Service.getRowData30();
        List<DataVo> closeData = stockDetailService.getRowData();
        statService.statisticsEma(closeData);
        return "success!";
    }

    @RequestMapping("detail")
    public Object detail() {
        List<DataVo> closeData = stockDetailService.getRowData();
        BigDecimal finalMoney = stockStatService.analysisEmaUpDown(528, 384, closeData,true);
        return finalMoney;
    }

    @RequestMapping("adjust")
    public Object adjust() {
        emaComponent.startStatistics();
        List<DataVo> closeData = stockDetailService.getRowData();
        statService.statisticsEmaAdjust(528, 384, closeData);
        return "success";
    }

    @RequestMapping("adjust0")
    public Object adjust0() {
        emaComponent.startStatistics();
        List<DataVo> closeData = stockDetailService.getRowData();
        return stockStatService.analysisEmaAdjust(528, 384, closeData,BigDecimal.ZERO);
    }


}
